# coding: utf-8
from typing import List, Union

from pydantic import BaseModel, Field


class BookItemModel(BaseModel):
    """
    书籍项目模型
    """
    title: str = Field(..., max_length=100, description="书籍名称")
    desc: str = Field('', description="书籍简介")
    cover: str = Field('', description="书籍封面")
    tags: Union[List[str], str] = Field([], description="书籍标签")
    info_url: str = Field('', description="书籍详情页链接")
    rank: int = Field(0, description="书籍排名")
    source: object = Field(None, description="书籍来源")
    photo_url: str = Field('', description="照片链接")


class BookInfoModel(BaseModel):
    """
    书籍详情模型
    """
    title: str = Field(..., max_length=100, description="书籍名称")
    author: str = Field('', max_length=100, description="书籍作者")
    cover: str = Field('', description="书籍封面")
    desc: str = Field('', description="书籍简介")
    tags: Union[List[str], str] = Field([], description="书籍标签")
    url: str = Field('', description="书籍详情页链接")
    chapters: List[BookItemModel] = Field([], description="章节列表")
    score: Union[float, str] = Field(0.0, description="书籍评分")
    peopleNum: int = Field(0, description="人气")
    status: str = Field('', max_length=100, description="书籍状态")
    lastUpdate: str = Field('', max_length=100, description="最近更新时间")
    latestChapterName: str = Field('', max_length=100, description="最新章节")
    latestChapterUrl: str = Field('', description="最新章节链接")
    source: object = Field(None, description="书籍来源")
    useBrowser: bool = Field(False, description="是否使用浏览器打开")


class HomeItemModel(BaseModel):
    """
    首页项目模型
    """
    title: str = Field(..., max_length=100, description="项目名称")
    desc: str = Field('', max_length=100, description="项目简介")
    more_url: str = Field('', description="更多链接")
    comicList: List[BookItemModel] = Field([], description="书籍列表")
    source: object = Field(None, description="书籍来源")


class SearchResultModel(BaseModel):
    """
    搜索结果模型
    """
    keyword: str = Field(..., max_length=100, description="搜索关键字")
    desc: str = Field('', description="搜索结果简介")
    comicList: List[BookItemModel] = Field([], description="书籍列表")
    source: object = Field(None, description="书籍来源")


class ChapterPhotoModel(BaseModel):
    """
    章节图片模型
    """
    width: int = Field(800, description="图片宽度")
    min_height: int = Field(500, description="图片最小高度")
    urls: List[str] = Field([], description="图片链接列表")
    source: object = Field(None, description="图片来源")
